<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>魏远商城</title>
		<meta name="viewport" content="initial-scale=1, maximum-scale=1">
		<link rel="shortcut icon" href="/favicon.ico">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="css/my-order.css" />
		<link rel="stylesheet" href="css/style.css" />
		<style>
			body {
				background-color: white!important;
			}
			
			.contentall {
				padding-top: 2rem;
			}
			
			.home-dan>p:nth-child(4) {
				font-size: .8rem;
			}
			
			.home-dan>p:nth-child(2) {
				font-size: .7rem;
			}
			
			.home-dan>p:nth-child(3) {
				font-size: .6rem;
			}
			.hone-recommend>p:nth-child(1){
				font-size: 14px;
				margin-bottom: 5px;
			}
		</style>
	</head>

	<body style="background: #eaeef1;">
		<header class="bar bar-nav return-header" style="width: 100%;">
			<span class="order-back mui-action-back"><img src="img/back-le.png" height="50%"/></span>
			<h1 class="title" style="line-height: 2.2rem;">营销活动</h1>
		</header>

		<div class="contentall">

		</div>

		<script src="js/mui.min.js"></script>
		<script src="js/jquery-3.1.1.min.js"></script>
		<script src="js/url.js"></script>
		<script type="text/javascript">
//			mui.init({
//				swipeBack: true //启用右滑关闭功能
//			});
//
//          mui.plusReady(function() {
//				showlist();
//			});
            
            showlist();
			$('.contentall').on('tap', '.home-dan', function() {
				//				alert(111);
				//              alert($(this).attr('id'));
				href('details.html', $(this).attr('id'));
			});

			function href(a, c) {
				localStorage.whereId = c;
				mui.openWindow({
					url: a,
					show: {
						aniShow: 'pop-in'
					}
				})
			}

			

			function showlist() {
				//					alert(localStorage.numtowhere);
//				plus.nativeUI.showWaiting();	
				if(localStorage.numtowhere == 59) {
					$('.title').text('营销活动');
				} else if(localStorage.numtowhere == 64) {
					$('.title').text('优品馆');
				} else if(localStorage.numtowhere == 65) {
					$('.title').text('新品速递');
				} else if(localStorage.numtowhere == 66) {
					$('.title').text('热销爆款');
				}
				$.ajax({
					url: ur + '/mobile/product/getMarketingProductList',
					type: 'POST',
					headers: {
						"X-Token": localStorage.token,
					},
					dataType: 'json',
					data: {
						"num": localStorage.numtowhere
					},
					success: function(data) {
//						plus.nativeUI.closeWaiting();
						console.log(data);
						//						console.log(data.length);
						console.log(data.categoryStrs.length);

						for(var i = 0; i < data.categoryStrs.length; i++) {

							var div = ('<div class="hone-recommend" style="margin-bottom: 0;"> ' +
								'<p style="text-align: center;">—— ' + data.categoryStrs[i] + ' ——</p> ' +
//								'<p id="' + i + '" class=""></p> ' +
								'<div class="home-se' + i + ' home-se">' +
								'</div> </div>');
							$('.contentall').append(div);

							var keys = 'category' + i;
							console.log(data[keys].length);
							for(var y = 0; y < data[keys].length; y++) {
								var b = data[keys][y].mainImg;
								console.log(b.indexOf(',') + '逗号索引值');
								var m = b.indexOf(',');
								if(m != '-1') {
									var mainImg = b.substring(0, m);
								} else {
									mainImg = b;
								}
								var divdan = ('<div class="home-dan" id=' + data[keys][y].id + '> ' +
									'<div class="home-picd" style="background-image: url(' + picur + mainImg + ');background-position: center;background-repeat: no-repeat;background-size: cover;"></div> ' +
									'<p>' + data[keys][y].shortname + '</p> ' +
									'<p>' + data[keys][y].longname + '</p>' +
									'<p>¥<span style="font-size: 1rem;">' + data[keys][y].newPrice + '</span>' +
									//									'<span class="home-add"><img src="img/add.png" alt="" width="50%"/></span>' +
									'</p> ' +
									'</div>');
								$('.home-se' + i + '').append(divdan);
							}
						}
					},
					 error:function(){
//					 	plus.nativeUI.closeWaiting();
					 }
				});
			}
		</script>
	</body>

</html>